class User {

  String? id;
  String? userName;
  String? password;
  String? userCode;
  String? sex;
  String? workshopId;
  String? postId;
  String? remark;
  String? active;
  String? createUid;
  String? createDate;
  String? writeUid;
  String? writeDate;

  User({
    this.id,
    this.userName,
    this.password,
    this.userCode,
    this.sex,
    this.workshopId,
    this.postId,
    this.remark,
    this.active,
    this.createUid,
    this.createDate,
    this.writeUid,
    this.writeDate,
  });

  User copyWith({
    String? id,
    String? userName,
    String? password,
    String? userCode,
    String? sex,
    String? workshopId,
    String? postId,
    String? remark,
    String? active,
    String? createUid,
    String? createDate,
    String? writeUid,
    String? writeDate,
  }) {
    return new User(
      id: id ?? this.id,
      userName: userName ?? this.userName,
      password: password ?? this.password,
      userCode: userCode ?? this.userCode,
      sex: sex ?? this.sex,
      workshopId: workshopId ?? this.workshopId,
      postId: postId ?? this.postId,
      remark: remark ?? this.remark,
      active: active ?? this.active,
      createUid: createUid ?? this.createUid,
      createDate: createDate ?? this.createDate,
      writeUid: writeUid ?? this.writeUid,
      writeDate: writeDate ?? this.writeDate,
    );
  }

  @override
  String toString() {
    return 'User{id: $id, userName: $userName, password: $password, userCode: $userCode, sex: $sex, workshopId: $workshopId, postId: $postId, remark: $remark, active: $active, createUid: $createUid, createDate: $createDate, writeUid: $writeUid, writeDate: $writeDate}';
  }

  @override
  bool operator ==(Object other) => identical(this, other) || (
      other is User &&
          runtimeType == other.runtimeType &&
          id == other.id &&
          userName == other.userName &&
          password == other.password &&
          userCode == other.userCode &&
          sex == other.sex &&
          workshopId == other.workshopId &&
          postId == other.postId &&
          remark == other.remark &&
          active == other.active &&
          createUid == other.createUid &&
          createDate == other.createDate &&
          writeUid == other.writeUid &&
          writeDate == other.writeDate);

  // @override
  // int get hashCode => userName.hashCode ^ password.hashCode;

  factory User.fromMap(Map<String, dynamic> map) {
    return new User(
      id: map['id'].toString() as String?,
      userName: map['user_name'] as String?,
      password: map['password'] as String?,
      userCode: map['user_code'] as String?,
      sex: map['sex'].toString() as String?,
      workshopId: map['workshop_id'][0].toString() as String?,
      postId: map['post_id'].toString() as String?,
      remark: map['remark'] as String?,
      active: map['active'] as String?,
      createUid: map['create_uid'].toString() as String?,
      createDate: map['create_date'] as String?,
      writeUid: map['write_uid'].toString() as String?,
      writeDate: map['write_date'] as String?,
    );
  }

  Map<String, dynamic> toMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'userName': this.userName,
      'password': this.password,
      'userCode': this.userCode,
      'sex': this.sex,
      'workshopId': this.workshopId,
      'postId': this.postId,
      'remark': this.remark,
      'active': this.active,
      'createUid': this.createUid,
      'createDate': this.createDate,
      'writeUid': this.writeUid,
      'writeDate': this.writeDate,
    } as Map<String, dynamic>;
  }

  List toDomainList() {
    List list = [
      if(this.id!=null&&this.id!='')['id','=',this.id],
      if(this.userName!=null&&this.userName!='')['user_name','like','%${this.userName}%'],
      if(this.password!=null&&this.password!='')['password','=',this.password],
      if(this.userCode!=null&&this.userCode!='')['user_code','like','%${this.userCode}%'],
      if(this.sex!=null&&this.sex!='')['sex','=',this.sex],
      if(this.workshopId!=null&&this.workshopId!='')['workshop_id','=',this.workshopId],
      if(this.postId!=null&&this.postId!='')['post_id','=',this.postId],
      if(this.remark!=null&&this.remark!='')['remark','=',this.remark],
      if(this.active!=null&&this.active!='')['active','=',this.active],
    ] as List;
    if(list.length==0){
      list.add(['id','!=',null]);
    }
    // ignore: unnecessary_cast
    return list;
  }

  Map<String, dynamic> toOdooMap() {
    // ignore: unnecessary_cast
    return {
      'id': this.id,
      'user_name': this.userName,
      'password': this.password,
      'user_code': this.userCode,
      'sex': this.sex,
      'workshop_id': this.workshopId,
      'post_id': this.postId,
      'remark': this.remark,
      'active': this.active,
      'create_uid': this.createUid,
      'create_date': this.createDate,
      'write_uid': this.writeUid,
      'write_date': this.writeDate,
    } as Map<String, dynamic>;
  }

//</editor-fold>

}
